package com.pearadmin.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pearadmin.common.nucleus.domain.request.PageParam;
import com.pearadmin.system.domain.SysRole;
import com.pearadmin.system.domain.SysUser;
import com.pearadmin.system.mapper.SysUserMapper;
import com.pearadmin.system.service.ISysUserService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper,SysUser> implements ISysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public boolean save(SysUser entity) {
        return super.save(entity);
    }

    @Override
    public PageInfo<SysUser> page(PageParam pageParam, SysUser sysUser) {
        PageHelper.startPage(pageParam.getPage(),pageParam.getLimit());
        List<SysUser> list = sysUserMapper.selectList(sysUser);
        return new PageInfo<>(list);
    }

    @Override
    public List<SysUser> list(SysUser sysUser) {
        return sysUserMapper.selectList(sysUser);
    }

    @Override
    public boolean removeById(String id) {
        int i = sysUserMapper.deleteById(id);
        if(i>0){
            return true;
        }else{
            return false;
        }
    }


    @Override
    public SysUser getById(String id) {
        return sysUserMapper.selectById(id);
    }

    @Override
    public boolean removeByIds(String[] ids) {
        int i = sysUserMapper.deleteByIds(ids);
        if(i>0){
            return true;
        }else{
            return false;
        }

    }
}
